package qcmPlus.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;

import qcmPlus.beans.Questionnaire;
import qcmPlus.beans.ReponseStagiaire;
import qcmPlus.tools.HibernateUtil;

public class ReponseStagiaireDAO {

	private List<ReponseStagiaire> listeReponseStagiaires = new ArrayList<ReponseStagiaire>();

	@SuppressWarnings("unchecked")
	public List<ReponseStagiaire> liste(int idQuestion) {

		ArrayList<ReponseStagiaire> temp = null;
		Session s = HibernateUtil.currentSession();

		temp = (ArrayList<ReponseStagiaire>) s.createQuery(
				"from ReponseStagiaire where ID_QUESTION=" + idQuestion +" order by ID_REPONSE asc" ).list();
		if (temp.size() > 0) {
			for (ReponseStagiaire r : temp) {
				listeReponseStagiaires.add(r);
			}
		}

		HibernateUtil.closeSession();
		return listeReponseStagiaires;
	}
	
	

	public String insertion(String nom, String description) 
	{
		Session s = HibernateUtil.currentSession();
		ReponseStagiaire reponse = new ReponseStagiaire();
		s.save(reponse);
		HibernateUtil.closeSession();
		return "ok";
	}
	

	
		
}
